package android.itv.view;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.itv.R;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class Main extends Activity
{
    Button btntivi, btnnotifications,btnAbout;
    int a=0;
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        btntivi=(Button)findViewById(R.id.btntivi);
        btnnotifications=(Button)findViewById(R.id.btnnotifications);
        btnAbout=(Button)findViewById(R.id.btnabout);
        	
        
        btntivi.setOnClickListener(clickTivi);
        btnnotifications.setOnClickListener(clickNotifications);
        btnAbout.setOnClickListener(clickAbout);
    }
    
    private View.OnClickListener clickTivi=new OnClickListener()
    {
        
        @Override
        public void onClick(View v)
        {
    		Intent i=new Intent(getApplicationContext(),Watch.class);
    		startActivity(i);
        }
    };
    
    private View.OnClickListener clickNotifications=new OnClickListener()
    {
        
        @Override
        public void onClick(View v)
        {
            Intent i=new Intent(getApplicationContext(),ViewNotifications.class);
            startActivity(i);
        }
    };
    
    private View.OnClickListener clickAbout=new OnClickListener()
    {
        
        @Override
        public void onClick(View v)
        {
            showDialog(0);
        }
    };
    
    protected android.app.Dialog onCreateDialog(int id) 
    {
	AlertDialog.Builder dialog=new AlertDialog.Builder(this);
	dialog.setIcon(R.drawable.tv);
	dialog.setTitle(R.string.txttitleabout);
	dialog.setMessage(R.string.txtabout);	
	return dialog.create();
    };
    
    private void createDialogError()
    {
	AlertDialog.Builder builder=new AlertDialog.Builder(this);
	
	builder.setTitle(R.string.txtalter);
	builder.setIcon(android.R.drawable.alert_light_frame);
	builder.setMessage(R.string.txtexit);
	builder.setPositiveButton(R.string.txtok, new DialogInterface.OnClickListener()
	{
	    
	    @Override
	    public void onClick(DialogInterface dialog, int which)
	    {
		finish();
	    }
	});
	
	builder.setNegativeButton(R.string.txtcancel, new DialogInterface.OnClickListener()
	{
	    
	    @Override
	    public void onClick(DialogInterface dialog, int which)
	    {
	    }
	});
	builder.create().show();
    }
    

    @Override
    public void onBackPressed()
    {
	createDialogError();	
    }
}
